#include "With.h"
#include "IVisitor.h"

With::With(const WithItemTypeList& with_item, const suiteTypePtr& body, int nodeId):
    stmtType(nodeId),
    _with_item(with_item),
    _body(body)
{
}
    
With::~With()
{
    _with_item.clear();
}
    
QString With::type() const
{
    return "With";
}
    

WithItemTypeList With::with_item()
{
    return _with_item;
}

void With::setWith_item(const WithItemTypeList& with_item)
{
    _with_item = with_item;
}

suiteTypePtr With::body()
{
    return _body;
}

void With::setBody(const suiteTypePtr& body)
{
    _body = body;
}

    
QString With::toString() const
{
    return QString("With[with_item=%1, body=%2]").
                arg(_with_item.toString()).
                arg(_body ? _body->toString():"");
}
    
void With::accept(IVisitor* visitor, const SimpleNodePtr& node)
{
    visitor->visitWith(node.dynamicCast<With>());
}
    
void With::traverse(IVisitor* visitor)
{
    _with_item.traverse(visitor);
    if (_body != NULL)
        _body->accept(visitor, _body);
}